package com.ziyia.a222;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ActionMenuView;
import android.widget.AdapterView;
import android.widget.AdapterViewFlipper;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.BaseAdapter;
import android.widget.BaseExpandableListAdapter;
import android.widget.CursorTreeAdapter;
import android.widget.ExpandableListView;
import android.widget.HeaderViewListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.MultiAutoCompleteTextView;
import android.widget.SimpleAdapter;
import android.widget.StackView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.WrapperListAdapter;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends AppCompatActivity {

    private int[] strings = {R.drawable.user, R.drawable.e4e27d23adc37f3dd503c5dea5cd459, R.drawable.e9d94a9a8e1fd4cb2f44b6654835674};

    StackView stackView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        stackView = findViewById(R.id.sstackview);

        List<Map<String, Object>> mapList = new ArrayList<>();
        for (int i = 0; i < strings.length; i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("image", strings[i]);
            mapList.add(map);
        }

        SimpleAdapter simpleAdapter = new SimpleAdapter(this, mapList, R.layout.item, new String[]{"image"}, new int[]{R.id.image});

        stackView.setAdapter(simpleAdapter);


        stackView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(MainActivity.this, "年少有为", Toast.LENGTH_SHORT).show();
            }
        });

    }

    public void next(View view) {
        stackView.showNext();
    }

    public void prev(View view){

        stackView.showPrevious();
    }

}